home *** CD-ROM | disk | FTP | other *** search
- Path: krel.iea.com!usenet
- From: fleckm@comtch.iea.com@iea.com
- Newsgroups: comp.lang.c
- Subject: Re: Limiting stdin input to "n" chars
- Date: 25 Mar 1996 15:51:05 GMT
- Organization: CompuTech
- Message-ID: <4j6fd9$3o4@krel.iea.com>
- References: <4hqfmc$un7@thorn.cc.usm.edu> <4icer1$df5@altrade.nijmegen.inter.nl.net> <4if7k6$9ro@news.xs4all.nl> <4j1i39$jso@nntp1.best.com>
- Reply-To: fleckm@comtch.iea.com@iea.com
- NNTP-Posting-Host: cda0-10.iea.com
- X-Newsreader: IBM NewsReader/2 v1.2
-
- In <4j1i39$jso@nntp1.best.com>, Zenin <zenin@best.com> writes:
- > What I'm trying to do is simply ask a y/n question of the user so
- > that they only have to enter "y" or "n" without having to also give
- > the anoying line feed.
- >
- > I thought simply
- > int c;
- > c = getchar();
- > if (c ==...etc...
- > would do it, but of course I'm wrong... :(
-
- You could try:
-
- char ch;
-
- ch=getch();
-
- if (ch='Y' || ch='y') // allow lower or upper case
- {
- stuff
- }
-
-
- Mike in Coeur d'Alene
-